
function PixelOrder(width, height)
{
  var _width = width;
  var _height = height;

  var _stride = 128;
  var _i = 0, _j = 0;

  this.next = function()
  {
    if(_stride == 0)
      return false;

    _i += _stride;
    if(_i >= _width)
    {
      _i = 0;
      _j += _stride;
    }
    if(_j >= _height)
    {
      _stride >>= 1;
      if(_stride == 0)
        return false;

      _i = _j = 0;
    }

    return true;
  }

  this.__defineGetter__('pixel', function() { return [_i, _j]; });

  this.__defineGetter__('stride', function() { return _stride; });


  return this;
}
PixelOrder.prototype = new Object();
PixelOrder.prototype.constructor = PixelOrder;
